package com.orientsec.autotest.project.system.systemSet.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.orientsec.autotest.framework.aspectj.lang.annotation.Log;
import com.orientsec.autotest.framework.aspectj.lang.enums.BusinessType;
import com.orientsec.autotest.project.system.systemSet.domain.SystemSet;
import com.orientsec.autotest.project.system.systemSet.service.ISystemSetService;
import com.orientsec.autotest.framework.web.controller.BaseController;
import com.orientsec.autotest.framework.web.page.TableDataInfo;
import com.orientsec.autotest.framework.web.domain.AjaxResult;
import com.orientsec.autotest.common.utils.poi.ExcelUtil;

/**
 * 执行网关配置信息操作处理
 * 
 * @author autotest
 * @date 2019-12-26
 */
@Controller
@RequestMapping("/system/systemSet")
public class SystemSetController extends BaseController
{
    private String prefix = "system/systemSet";
	
	@Autowired
	private ISystemSetService systemSetService;
	
	@RequiresPermissions("system:systemSet:view")
	@GetMapping()
	public String systemSet()
	{
	    return prefix + "/systemSet";
	}
	
	/**
	 * 查询执行网关配置列表
	 */
	@RequiresPermissions("system:systemSet:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(SystemSet systemSet)
	{
		startPage();
        List<SystemSet> list = systemSetService.selectSystemSetList(systemSet);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出执行网关配置列表
	 */
	@RequiresPermissions("system:systemSet:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SystemSet systemSet)
    {
    	List<SystemSet> list = systemSetService.selectSystemSetList(systemSet);
        ExcelUtil<SystemSet> util = new ExcelUtil<SystemSet>(SystemSet.class);
        return util.exportExcel(list, "systemSet");
    }
	
	/**
	 * 新增执行网关配置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存执行网关配置
	 */
	@RequiresPermissions("system:systemSet:add")
	@Log(title = "执行网关配置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(SystemSet systemSet)
	{		
		return toAjax(systemSetService.insertSystemSet(systemSet));
	}

	/**
	 * 修改执行网关配置
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		SystemSet systemSet = systemSetService.selectSystemSetById(id);
		mmap.put("systemSet", systemSet);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存执行网关配置
	 */
	@RequiresPermissions("system:systemSet:edit")
	@Log(title = "执行网关配置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(SystemSet systemSet)
	{		
		return toAjax(systemSetService.updateSystemSet(systemSet));
	}
	
	/**
	 * 删除执行网关配置
	 */
	@RequiresPermissions("system:systemSet:remove")
	@Log(title = "执行网关配置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(systemSetService.deleteSystemSetByIds(ids));
	}
	
}
